<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>汽车入库</title>
    <link rel="stylesheet" type="text/css" href="/easyui/themes/metro/easyui.css" />
    <link rel="stylesheet" type="text/css" href="/css/wu.css" />
    <link rel="stylesheet" type="text/css" href="/css/icon.css" />
    <script type="text/javascript" src="/js/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/easyui/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="/easyui/datagrid-detailview.js"></script>

</head>
<body>
    <!-- 查询条件开始 -->
    <div class="easyui-panel" data-options="title:'查询条件',iconCls:'icon-search',width:'100%'" style="margin-bottom: 3px;text-align: left;padding: 10px">
        <input class="easyui-searchbox" id="searchValue" data-options="prompt:'请输入出租单号',searcher:doSearch" style="width:40%">
    </div>
    <!-- 查询条件结束 -->

    <!-- 数据表格开始 -->
    <div id="myDiv">
        <!-- 检查单的表单开始 -->
        <div class="easyui-panel" data-options="title:'生成检查单',iconCls:'icon-save'"  >
            <form action="" method="post" id="dataFrm">
                <table width="100%" align="center" cellpadding="5" style="padding-left: 50px;padding-right: 60px">
                    <tr>
                        <td width="50%"><input class="easyui-textbox"  name="checkid" data-options="label:'检查单号:',labelAlign:'right',labelPosition:'left',width:'100%',required:true,prompt:'请输入检查单号',readonly:true"></td>
                        <td width="50%"><input class="easyui-datetimebox" name="checkdate" data-options="label:'检查时间:',labelAlign:'right',labelPosition:'left',width:'100%',required:true,prompt:'请选择检查时间',editable:false"></td>
                    </tr>
                    <tr>
                        <td width="50%"><input class="easyui-textbox"  name="rentid" data-options="label:'出租单号:',labelAlign:'right',labelPosition:'left',width:'100%',required:true,prompt:'请输入出租单号',readonly:true"></td>
                        <td width="50%"><input class="easyui-textbox"  name="opername" data-options="label:'操作员:',labelAlign:'right',labelPosition:'left',width:'100%',required:true,prompt:'请输入租操作员',readonly:true"></td>
                    </tr>
                    <tr>
                        <td width="50%"><input class="easyui-textbox"  name="problem" data-options="label:'存在问题:',labelAlign:'right',labelPosition:'left',width:'100%',required:true,prompt:'请输入存在问题'"></td>
                        <td width="50%"><input class="easyui-numberbox"  name="paymoney" data-options="label:'赔付金额:',labelAlign:'right',labelPosition:'left',width:'100%',required:true,prompt:'请输入赔付金额'"></td>
                    </tr>
                    <tr>
                        <td width="100%" colspan="2">
                            <input class="easyui-textbox"  name="checkdesc" data-options="label:'问题描述:',labelAlign:'right',labelPosition:'left',width:'100%',height:40,required:true,prompt:'请输入问题描述',multiline:true">
                        </td>
                    </tr>
                    <tr>
                        <td width="100%" colspan="2" align="center">
                            <a href="#" class="easyui-linkbutton" id="doSubmit"  data-options="iconCls:'icon-save'">保存</a>
                        </td>
                    </tr>
                </table>
            </form>
        </div>
        <!-- 检查单的表单结束 -->
        <div class="easyui-layout" data-options="width:'100%',height:300" style="margin-top: 3px">
            <!-- 车辆信息 -->
            <div class="easyui-panel" data-options="region:'west',title:'车辆信息',iconCls:'icon-tip',width:'33%',height:'100%'">
                <table width="100%" cellpadding="5" style="padding: 20px">
                    <tr>
                        <td align="right" width="35%">车辆号牌:</td>
                        <td id="car_carnumber"></td>
                    </tr>
                    <tr>
                        <td align="right" >车辆类型:</td>
                        <td id="car_cartype"></td>
                    </tr>
                    <tr>
                        <td align="right" >车辆颜色:</td>
                        <td id="car_color"></td>
                    </tr>
                    <tr>
                        <td align="right" >购买价格:</td>
                        <td id="car_price"></td>
                    </tr>
                    <tr>
                        <td align="right" >默认出租价格:</td>
                        <td id="car_rentprice"></td>
                    </tr>
                    <tr>
                        <td align="right" >出租押金:</td>
                        <td id="car_deposit"></td>
                    </tr>
                    <tr>
                        <td align="right" >车辆描述:</td>
                        <td id="car_description"></td>
                    </tr>
                    <tr>
                        <td align="right" >车辆图片:</td>
                        <td >
                            <img alt="车辆图片" id="car_carimg" width="120" height="80" src="">
                        </td>
                    </tr>
                </table>
            </div>
            <!-- 出租单信息 -->
            <div class="easyui-panel" data-options="region:'center',title:'出租单信息',iconCls:'icon-tip',width:'33%',height:'100%'">
                <table width="100%" cellpadding="5" style="padding: 20px">
                    <tr>
                        <td align="right" width="35%">出租单号:</td>
                        <td id="rent_rentid"></td>
                    </tr>
                    <tr>
                        <td align="right" >出租价格:</td>
                        <td id="rent_price"></td>
                    </tr>
                    <tr>
                        <td align="right" >起租时间:</td>
                        <td id="rent_begindate"></td>
                    </tr>
                    <tr>
                        <td align="right" >还车时间:</td>
                        <td id="rent_returndate"></td>
                    </tr>
                    <tr>
                        <td align="right" >操作员:</td>
                        <td id="rent_opername"></td>
                    </tr>

                </table>
            </div>
            <!-- 客户信息 -->
            <div class="easyui-panel" data-options="region:'east',title:'客户信息',iconCls:'icon-tip',width:'33%',height:'100%'">
                <table width="100%" cellpadding="5" style="padding: 20px">
                    <tr>
                        <td align="right" width="35%">身份证号:</td>
                        <td id="cust_identity"></td>
                    </tr>
                    <tr>
                        <td align="right" >客户姓名:</td>
                        <td id="cust_custname"></td>
                    </tr>
                    <tr>
                        <td align="right" >客户性别:</td>
                        <td id="cust_sex"></td>
                    </tr>
                    <tr>
                        <td align="right" >客户地址:</td>
                        <td id="cust_address"></td>
                    </tr>
                    <tr>
                        <td align="right" >客户电话:</td>
                        <td id="cust_phone"></td>
                    </tr>
                    <tr>
                        <td align="right" >客户职业:</td>
                        <td id="cust_career"></td>
                    </tr>
                </table>
            </div>

        </div>


    </div>
    <!-- 数据表格结束 -->
</body>
<script type="text/javascript">

        //隐藏myDiv
        $(function () {
            $("#myDiv").hide();
        });

        //searchbox的查询方法
        function doSearch() {
            var value = $("#searchValue").val();
            console.log(value);
            $.post("/check/checkRentIdtIsExit", {rentid: value}, function (obj) {
                if (obj === "") {
                    $.messager.show({
                        title: '提示',
                        msg: '出租单号不存在,请核对后再查询'
                    });
                    $("#myDiv").hide();
                } else {
                    if (obj.rentflag == 0) {
                        $("#myDiv").show();
                        initCheckFromData();
                    } else {
                        $.messager.show({
                            title: '提示',
                            msg: '当前出租单相关车辆已归还'
                        });
                    }
                }
            })
        };

        //初始化表单及其它数据
        function initCheckFromData() {
            var rentid = $("#searchValue").val();
            $.post("/check/initCheckCarForm", {rentid: rentid}, function (map) {
                //装载检查表单
                var check = map.check;
                $("#dataFrm").form("load", check);
                //车辆
                var car = map.car;
                $("#car_carnumber").html(car.carnumber);
                $("#car_cartype").html(car.cartype);
                $("#car_color").html(car.color);
                $("#car_price").html(car.price);
                $("#car_rentprice").html(car.rentprice);
                $("#car_deposit").html(car.deposit);
                $("#car_description").html(car.description);
                //$("#car_carimg").html(car.carimg);
                $("#car_carimg").attr("src","/file/downloadShowFile?path="+car.carimg);
                //出租单
                var rent = map.rent;
                $("#rent_rentid").html(rent.rentid);
                $("#rent_price").html(rent.price);
                $("#rent_begindate").html(rent.begindate);
                $("#rent_returndate").html(rent.returndate);
                $("#rent_opername").html(rent.opername);
                //客户
                var customer = map.customer;
                $("#cust_identity").html(customer.identity);
                $("#cust_custname").html(customer.custname);
                $("#cust_sex").html(customer.sex == 0 ? '女' : '男');
                $("#cust_address").html(customer.address);
                $("#cust_phone").html(customer.phone);
                $("#cust_career").html(customer.career);
            })
        }


        //保存数据
        $("#doSubmit").click(function(){
            $.messager.progress();	// 显示进度条
            $("#dataFrm").form("submit",{
                url:"/check/saveCheckOrder",
                onSubmit: function(){
                    var isValid = $(this).form('validate');  //再次验证
                    if (!isValid){
                        $.messager.progress('close');	// 隐藏进度条
                    }
                    return isValid;	// 返回False则验证不能通过  阻止表单提交
                },
                success: function(result){
                    var result = eval('('+result+')');
                    $.messager.show({
                        title:'提示',
                        msg:result.msg
                    });
                    if(result.code>=0){//操作成功
                        //让carTable 隐藏
                        $("#myDiv").hide();
                    }
                    $.messager.progress('close');	// 隐藏进度条
                }
            });
        });
      /*  //保存(layer)
        form.on("submit(doSubmit)", function (obj) {
            //序列化表单数据
            var params = $("#dataFrm").serialize();
            $.post('/check/saveCheckOrder', params, function (obj) {
                layer.msg(obj.msg);
                $("#myDiv").hide();
            })
        });*/
</script>
</html>

